package com.sino.operation.system.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.sino.operation.commons.response.CenterResponseEntity;
import com.sino.operation.entity.BizHint;
import com.sino.operation.service.impl.BizHintServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @Title: HintController
 * @Description: 提示信息配置
 * @Author dengls
 * @date 2021/10/11 16:47
 */
@Slf4j
@RestController
@RequestMapping("hintInfoConfig")
@Api(value = "提示信息配置", tags = "增加、修改、删除、查询")
public class HintController {
    @Autowired
    private BizHintServiceImpl bizHintService;

    @GetMapping("/select")
    @ApiOperation(value = "查询提示信息配置列表")
    @ResponseBody
    public IPage<BizHint> getObjects(@RequestParam Map<String, String> map) {
        return bizHintService.selectList(map);
    }

    @PostMapping("/add")
    @ApiOperation(value = "新增提示信息")
    @ResponseBody
    public CenterResponseEntity addObject(BizHint BizHint) {
        try {
            bizHintService.saveOrUpdate(BizHint);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return CenterResponseEntity.build();
    }

    @PostMapping("/delete")
    @ApiOperation(value = "批量删除提示信息")
    @ResponseBody
    public CenterResponseEntity deleteObject(List ids) {
        try {
            bizHintService.removeByIds(ids);
        } catch (Exception e) {
            e.printStackTrace();
            return CenterResponseEntity.buildError();
        }
        return CenterResponseEntity.build();
    }

    @PostMapping("/update")
    @ApiOperation(value = "修改提示信息")
    @ResponseBody
    public CenterResponseEntity updateObject(BizHint BizHint) {
        try {
            bizHintService.saveOrUpdate(BizHint);
        } catch (Exception e) {
            e.printStackTrace();
            return CenterResponseEntity.buildError();
        }
        return CenterResponseEntity.build();
    }
}
